<h1><?php echo $__title ?></h1>
<?php if ( $__session->isAuthenticated() ): ?>
<div class="right" style="margin-bottom:25px">
    <?php if($__session->hasCredential('forums_moderate')): ?><a class="strong" href="<?php link_to('forum', 'forum', 'moderate', array($forum->getId(), slugify($forum->getTitle()))) ?>">Accès à la modération</a> | <?php endif ?>
    <a class="submit" style="margin-bottom:10px" href="<?php link_to('forum', 'forum', 'create-discussion', array($forum->getId(), slugify($forum->getTitle()))) ?>">Créer une discussion</a>
</div>
<?php endif ?>

<?php if (empty($discussions)): ?>
<p>Aucune discussion dans ce forum.</p>
<?php else: ?>
<table class="list">
<thead>
<tr>
    <th colspan="2">Discussions</th>
    <th class="checkbox">Messages</th>
    <th style="width:180px">Dernier message</th>
</tr>
</thead>
<tbody>
<?php foreach ($discussions AS $key => $discussion): ?>
<tr <?php if ($key % 2 == 1): ?>class="even"<?php endif ?>>
        <td style="width:32px"><?php if (!$discussion->isRead($__session)): ?><div class="icons-read"><span class="no-display">Non lu</span></div><?php endif ?></td>
        <td><a href="<?php link_to('forum', 'discussion', null, array($discussion->getId(), slugify($discussion->getTitle()))) ?>"><?php echo $discussion->getTitle() ?></a></td>
        <td class="center"><?php echo $discussion->getMessages()->count() ?></td>
        <td class="center">
<?php if ($discussion->getMessages()->isEmpty()): ?>
        Aucun message
<?php else: ?>
            <a class="icon-last" href="<?php link_to('forum', 'discussion', null, array($discussion->getId(), slugify($discussion->getTitle()))) ?>#message<?php echo $discussion->getMessages()->last()->getId() ?>"><?php echo resume($discussion->getMessages()->last()->getContent(), 10) ?></a><br />
            par <?php echo $forum->getDiscussions()->last()->getUser()->getLink() ?>
<?php endif; ?>
        </td>
    </tr>
<?php endforeach ?>
        </tbody>
    </table>


<?php if ( $__session->isAuthenticated() ): ?>
<div class="float-left table-list-legend border-radius bg-alpha">
    <div class="titre strong">Légende :</div>
    <div class="icons-read">Messages non lus</div>
</div>
<div class="right" style="margin-top:30px">
    <a href="<?php link_to('forum', 'forum', 'read', array($forum->getId(), slugify($forum->getTitle()))) ?>">Marquer tous les sujets comme lus</a> |
    <a class="submit" href="<?php link_to('forum', 'forum', 'create-discussion', array($forum->getId(), slugify($forum->getTitle()))) ?>">Créer une discussion</a>
</div>
<hr />
<?php endif ?>

<?php $pagination->render() ?>
<?php endif ?>
